﻿using System;
using System.IO;
using System.Reflection;

namespace ExcelUIMap
{

	public class UIMap
	{
		
		private string _excelfile;
		private Version _appversion;
		private UIMapItemCollection _mapdata;
		
		
		/// <summary>
		/// Get collection of uimap items
		/// </summary>
		public UIMapItemCollection Items
		{
			get
			{
				return _mapdata;
			}
		}
		
		/// <summary>
		/// Constructor from application name and version
		/// </summary>
		public UIMap(string application, string version)
		{
			//check
			if (String.IsNullOrEmpty(application)) throw new ArgumentNullException("No application name specified");
			if (String.IsNullOrEmpty(version)) throw new ArgumentNullException("No application version specified");
			//set properties
			_appversion = new Version(version);
			_excelfile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),application+".xlsx");
			//load excel
			_mapdata = ExcelLoader.LoadUIMap(_excelfile,_appversion);
		}
		
		
	}
}
